package com.unlcn.ils.erpInterfaces.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.unlcn.ils.erpInterfaces.api.vo.RestVO;
import com.unlcn.ils.erpInterfaces.dao.model.dto.VipcnDTO;
import com.unlcn.ils.erpInterfaces.service.buss.IDataExportService;
import com.unlcn.ils.erpInterfaces.service.util.BaseException;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dataExport")
@Api(value = "运力平台对接接口")
public class DataExportController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private IDataExportService exportService;


    //运力平台公众号使用率
    @PostMapping("/vipcn")
    public RestVO<List<VipcnDTO>> getVipcnExcel(@RequestBody Map<String,String> dto) {
        logger.info("DataExportController.dataExport/vipcn param:{}", JSONObject.toJSONString(dto));
        RestVO<List<VipcnDTO>> vo = new RestVO<>(0, "查询成功",true);
        try {
            List<VipcnDTO> list = exportService.getVipcnExcel(dto);
            vo.setData(list);
        } catch (BaseException be) {
            vo.setSuccess(false);
            vo.setCode(-1);
            vo.setMessage(be.getMessage());
        } catch (Exception e) {
            vo.setSuccess(false);
            vo.setCode(-1);
            vo.setMessage("系统异常");
        }
        return vo;
    }
}
